package com.roncoo.education.course.service.admin;

import java.util.List;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.roncoo.education.common.core.base.Page;
import com.roncoo.education.common.core.base.Result;
import com.roncoo.education.course.service.admin.biz.AdminOptionsBiz;
import com.roncoo.education.course.service.admin.req.AdminOptionsEditReq;
import com.roncoo.education.course.service.admin.req.AdminOptionsListReq;
import com.roncoo.education.course.service.admin.req.AdminOptionsPageReq;
import com.roncoo.education.course.service.admin.req.AdminOptionsSaveReq;
import com.roncoo.education.course.service.admin.resp.AdminOptionsListResp;
import com.roncoo.education.course.service.admin.resp.AdminOptionsPageResp;
import com.roncoo.education.course.service.admin.resp.AdminOptionsViewResp;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;

/**
 * ADMIN-资源（实验、课程、全景...）分类配置
 *
 * @author wujing
 */
@Api(tags = "ADMIN-资源（实验、课程、全景...）分类配置")
@RestController
@RequiredArgsConstructor
@RequestMapping("/course/admin/options")
public class AdminOptionsController {

    @NotNull
    private final AdminOptionsBiz biz;

    @ApiOperation(value = "系统配置列表", notes = "系统配置列表")
    @PostMapping(value = "/list")
    public Result<List<AdminOptionsListResp>> list(@RequestBody AdminOptionsListReq req) {
        return biz.list(req);
    }
    
    @ApiOperation(value = "资源（实验、课程、全景...）分类配置分页", notes = "资源（实验、课程、全景...）分类配置分页")
    @PostMapping(value = "/page")
    public Result<Page<AdminOptionsPageResp>> page(@RequestBody AdminOptionsPageReq req) {
        return biz.page(req);
    }

    @ApiOperation(value = "资源（实验、课程、全景...）分类配置添加", notes = "资源（实验、课程、全景...）分类配置添加")
    @PostMapping(value = "/save")
    public Result<String> save(@RequestBody @Valid AdminOptionsSaveReq req) {
        return biz.save(req);
    }

    @ApiOperation(value = "资源（实验、课程、全景...）分类配置查看", notes = "资源（实验、课程、全景...）分类配置查看")
    @ApiImplicitParam(name = "id", value = "主键ID", dataTypeClass = Long.class, paramType = "query", required = true)
    @GetMapping(value = "/view")
    public Result<AdminOptionsViewResp> view(@RequestParam Long id) {
        return biz.view(id);
    }

    @ApiOperation(value = "资源（实验、课程、全景...）分类配置修改", notes = "资源（实验、课程、全景...）分类配置修改")
    @PutMapping(value = "/edit")
    public Result<String> edit(@RequestBody @Valid AdminOptionsEditReq req) {
        return biz.edit(req);
    }

    @ApiOperation(value = "资源（实验、课程、全景...）分类配置删除", notes = "资源（实验、课程、全景...）分类配置删除")
    @ApiImplicitParam(name = "id", value = "主键ID", dataTypeClass = Long.class, paramType = "query", required = true)
    @DeleteMapping(value = "/delete")
    public Result<String> delete(@RequestParam Long id) {
        return biz.delete(id);
    }
}
